package com.itheima.test_demo;


import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.IOException;

public class PoiTest {
    public static void main(String[] args) throws IOException {
        //加载excel文件 创建workbook对象--工作簿
        XSSFWorkbook workbook = new XSSFWorkbook("C:\\Users\\王立平\\Desktop\\com.itheima.test.xlsx");

        //获得sheet对象--工作表
        XSSFSheet sheet = workbook.getSheetAt(0);

        System.out.println("sheet:"+sheet);
        //遍历得每一行数据的对象--row
        for (Row row : sheet) {
            System.out.println("row:"+sheet);
            //遍历获得每一个单元格对象--cell
            for (Cell cell : row) {
                System.out.println("cell:"+cell);
            }
        }
        workbook.close();
    }
}
